'''

setStyle()
QstyleFactory()  当前平台支持的样式
QApplication.setStyle()  设置样式

'''
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
class AppWidget(QWidget):
    def __init__(self,parent=None):
        super(AppWidget,self).__init__(parent)
        self.setWindowTitle("QSS")
        btn1=QPushButton(self)
        btn1.setText('按钮1')

        btn2 = QPushButton(self)
        btn2.setProperty('name','btn2')
        btn2.setText('按钮2')

        vbox=QVBoxLayout(self)
        vbox.addWidget(btn1)
        vbox.addWidget(btn2)

        # qssStyle='''
        # QPushButton[name='btn2']{background-color:red}
        # '''

        qssStyle = '''
               QPushButton{background-color:red}
               '''
        self.setStyleSheet(qssStyle)


if __name__ == '__main__':
    app=QApplication(sys.argv)
    win=AppWidget()
    win.show()
    sys.exit(app.exec_())